/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Gleydson
 */
@Entity
@Table(name = "laboratorio")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Laboratorio.findAll", query = "SELECT l FROM Laboratorio l"),
    @NamedQuery(name = "Laboratorio.findByDescricao", query = "SELECT l FROM Laboratorio l WHERE l.descricao = :descricao"),
    @NamedQuery(name = "Laboratorio.findByNumeroPredio", query = "SELECT l FROM Laboratorio l WHERE l.laboratorioPK.numeroPredio = :numeroPredio"),
    @NamedQuery(name = "Laboratorio.findByNumero", query = "SELECT l FROM Laboratorio l WHERE l.laboratorioPK.numero = :numero")})
public class Laboratorio implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected LaboratorioPK laboratorioPK;
    @Column(name = "descricao")
    private String descricao;
    @OneToMany(mappedBy = "laboratorio", fetch= FetchType.EAGER)
    private List<Reservas> reservasList;

    public Laboratorio() {
    }

    public Laboratorio(LaboratorioPK laboratorioPK) {
        this.laboratorioPK = laboratorioPK;
    }

    public Laboratorio(int numeroPredio, int numero) {
        this.laboratorioPK = new LaboratorioPK(numeroPredio, numero);
    }

    public LaboratorioPK getLaboratorioPK() {
        return laboratorioPK;
    }

    public void setLaboratorioPK(LaboratorioPK laboratorioPK) {
        this.laboratorioPK = laboratorioPK;
    }

    public String getDescricao() {
        return descricao;
    }

    public void setDescricao(String descricao) {
        this.descricao = descricao;
    }

    @XmlTransient
    public List<Reservas> getReservasList() {
        return reservasList;
    }

    public void setReservasList(List<Reservas> reservasList) {
        this.reservasList = reservasList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (laboratorioPK != null ? laboratorioPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Laboratorio)) {
            return false;
        }
        Laboratorio other = (Laboratorio) object;
        if ((this.laboratorioPK == null && other.laboratorioPK != null) || (this.laboratorioPK != null && !this.laboratorioPK.equals(other.laboratorioPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return laboratorioPK.toString();
    }
    
}
